package com.ruoyi.business;

import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * @author ：jiangguanjun
 * @description：用于 获取 request中的分页信息
 * @date ：2020/7/29 10:04
 */
public class PageConfig {


    public static MyPage getPage() {
        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = servletRequestAttributes.getRequest();
        Integer pageSize = ServletRequestUtils.getIntParameter(request, "pageSize", 10);
        Integer pageNum = ServletRequestUtils.getIntParameter(request, "pageNum", 1);
        MyPage myPage = new MyPage();
        myPage.setPageNum(pageNum);
        myPage.setPageSize(pageSize);
        return myPage;
    }


}
